//
//  SharDetailController.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/13.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "SharDetailController.h"
#import "SharDetailCommentCell.h"
#import "SharDetailImagesCell.h"
#import "SharDetailInfoCell.h"
#import "SharDetailTopCell.h"
#import "SharDetailBottom.h"
#import "SharDetailSetionView.h"
@interface SharDetailController ()
/** <#note#> */
@property (nonatomic, weak) SharDetailBottom *bottomView;
@end

@implementation SharDetailController



- (SharDetailBottom *)bottomView{
    
    if (!_bottomView) {
        
        SharDetailBottom *temp = (SharDetailBottom *)[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([SharDetailBottom class]) owner:nil options:nil].firstObject;
        
        CGFloat bottomViewH = IPhoneX ? 83 : 49;
        
        temp.frame = CGRectMake(0, KScreenH - bottomViewH, KScreenW, bottomViewH);
            
        
        _bottomView = temp;
        
        [self.view addSubview:temp];
        
    }
    
    return _bottomView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"晒单详情";
    
    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([SharDetailCommentCell class]) bundle:nil] forCellReuseIdentifier:[SharDetailCommentCell identifierStr]];
    
    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([SharDetailSetionView class]) bundle:nil] forHeaderFooterViewReuseIdentifier:[SharDetailSetionView identifierStr]];

    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([SharDetailImagesCell class]) bundle:nil] forCellReuseIdentifier:[SharDetailImagesCell identifierStr]];

    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([SharDetailInfoCell class]) bundle:nil] forCellReuseIdentifier:[SharDetailInfoCell identifierStr]];

    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([SharDetailTopCell class]) bundle:nil] forCellReuseIdentifier:[SharDetailTopCell identifierStr]];

    
    self.plainTableView.estimatedRowHeight = 300;
    self.plainTableView.estimatedSectionHeaderHeight = 0;
    self.plainTableView.estimatedSectionFooterHeight = 0;
    self.plainTableView.rowHeight = UITableViewAutomaticDimension;
    self.plainTableView.backgroundColor = viewBgGrey;
    
    
    CGFloat footerH = IPhoneX ? 103 : 69;
    UIView *footer = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenW - footerH, KScreenW, footerH)];
    footer.backgroundColor = viewBgGrey;
    self.plainTableView.tableFooterView = footer;
    
    
    UIView *hideLineView = [[UIView alloc]initWithFrame:CGRectMake(0, 239, KScreenW, 10)];
    
    hideLineView.backgroundColor = [UIColor whiteColor];
    
    [self.plainTableView addSubview:hideLineView];
    
    self.bottomView.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    
    return 2;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    if (section == 0) {
        return 3;
    }else{
        
        return 20;
        
    }
    
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            SharDetailTopCell *cell = [tableView dequeueReusableCellWithIdentifier:[SharDetailTopCell identifierStr]];
            
            return cell;
        } else if (indexPath.row == 1){
            SharDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:[SharDetailInfoCell identifierStr]];
            
            return cell;
        }else{
            
            SharDetailImagesCell *cell = [tableView dequeueReusableCellWithIdentifier:[SharDetailImagesCell identifierStr]];
            
            return cell;
            
            
        }
        
    } else {
        
        
        SharDetailCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:[SharDetailCommentCell identifierStr]];
        
        return cell;
        
    }
    
 
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    return [[UIView alloc]init];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    
    if (section == 0) {
        
        return [[UIView alloc]init];
        
    } else {
        
        SharDetailSetionView *temp = (SharDetailSetionView *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:[SharDetailSetionView identifierStr]];
        
        
        return temp;
        
        
    }

    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
      return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    
    
    if (section == 0) {
        return 0;
    } else {
        return 36;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
